﻿// Copyright (c) egmkang wang. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace XServer.GrainInterfaces
{
    using System.Threading.Tasks;
    using Orleans.Concurrency;

    public interface ISendMessage
    {
        /// <summary>
        /// Grain发送序列化好的消息给Gateway
        /// </summary>
        /// <param name="destType">目标类型</param>
        /// <param name="dest">目标的ID</param>
        /// <param name="buffer">序列化好的消息</param>
        Task SendMessage(int destType, long dest, Immutable<byte[]> buffer);

        /// <summary>
        /// Gateway发送消息给Grain
        /// </summary>
        /// <param name="msgid">消息ID</param>
        /// <param name="buffer">序列化好的消息</param>
        /// <returns>返回</returns>
        Task RecvMessage(ushort msgid, Immutable<byte[]> buffer);

        /// <summary>
        /// 注册一个观察者
        /// </summary>
        /// <param name="key">观察者的Key</param>
        /// <param name="ob">观察者</param>
        /// <returns>TaskDone</returns>
        Task RegisterObserver(string key, IGatewayObserver ob);

        /// <summary>
        /// 注销一个观察者
        /// </summary>
        /// <param name="key">观察者的Key</param>
        /// <returns>TaskDone</returns>
        Task UnRegisterObserver(string key);
    }
}
